/*
 * PanelAtivos.java
 *
 * Created on 21 de Dezembro de 2006, 09:51
 */

package bvp.view;

import bvp.data.Cotacao;
import bvp.data.CotacaoTableModel;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author  rpanachi
 */
public class PanelAtivos extends javax.swing.JPanel
{
    private List <CotacaoTableModel> listCotacao;    
    
    /** Creates new form PanelAtivos */
    public PanelAtivos()
    {
        initComponents();
        listCotacao = new ArrayList <CotacaoTableModel> ();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents()
    {
        tabHistoricos = new javax.swing.JTabbedPane();

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(tabHistoricos, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 597, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(tabHistoricos, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTabbedPane tabHistoricos;
    // End of variables declaration//GEN-END:variables
 
    private CotacaoTableModel getModel(String codAtivo)
    {
        CotacaoTableModel result = null;
        
        try
        {
            
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
            
        }
        
        return result;
    }
    
    private void refreshModelos()
    {
        
    }
    
    public void addCotacaoHistorico(Cotacao cotacao)
    {
        try
        {
            CotacaoTableModel modelo = getModel(cotacao.getCodAtivo());
            
            if (modelo != null)
            {
                modelo.insert(cotacao);
            }          
            else
            {
                listCotacao.add(new CotacaoTableModel());
                modelo = getModel(cotacao.getCodAtivo());
                modelo.insert(cotacao);
            }            
        
            refreshModelos();            
        }
        catch (Exception ex)
        {
            ex.printStackTrace();            
        }
    }
}
